package com.edu.study.base.StuQuestionPaper.service.impl;

import java.util.List;

import com.edu.study.base.stuQuestionCatalog.service.IStuQuestionCatalogService;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.edu.study.base.StuQuestionPaper.mapper.StuQuestionPaperMapper;
import com.edu.study.base.StuQuestionPaper.domain.StuQuestionPaper;
import com.edu.study.base.StuQuestionPaper.service.IStuQuestionPaperService;

/**
 * 题卷Service业务层处理
 * 
 * @author jjt
 * @date 2021-05-20
 */
@Service
@DataSource(value = DataSourceType.SLAVE )
public class StuQuestionPaperServiceImpl implements IStuQuestionPaperService 
{
    @Autowired
    private StuQuestionPaperMapper stuQuestionPaperMapper;

    @Autowired
    private IStuQuestionCatalogService stuQuestionCatalogService;


    /**
     * 查询题卷
     * 
     * @param id 题卷ID
     * @return 题卷
     */
    @Override
    public StuQuestionPaper selectStuQuestionPaperById(Long id)
    {
        return stuQuestionPaperMapper.selectStuQuestionPaperById(id);
    }

    /**
     * 查询题卷列表
     * 
     * @param stuQuestionPaper 题卷
     * @return 题卷
     */
    @Override
    public List<StuQuestionPaper> selectStuQuestionPaperList(StuQuestionPaper stuQuestionPaper)
    {
        return stuQuestionPaperMapper.selectStuQuestionPaperList(stuQuestionPaper);
    }

    /**
     * 新增题卷
     * 
     * @param stuQuestionPaper 题卷
     * @return 结果
     */
    @Override
    public int insertStuQuestionPaper(StuQuestionPaper stuQuestionPaper)
    {
        stuQuestionPaper.setCreateTime(DateUtils.getNowDate());
        stuQuestionPaper.setUpdateTime(DateUtils.getNowDate());
        stuQuestionPaper.setCreateId(SecurityUtils.getUserId());
        stuQuestionPaper.setUpdateId(SecurityUtils.getUserId());
        int i = stuQuestionPaperMapper.insertStuQuestionPaper(stuQuestionPaper);
        return i;
    }


    /**
     * 修改题卷
     * 
     * @param stuQuestionPaper 题卷
     * @return 结果
     */
    @Override
    public int updateStuQuestionPaper(StuQuestionPaper stuQuestionPaper)
    {
        stuQuestionPaper.setUpdateTime(DateUtils.getNowDate());
        return stuQuestionPaperMapper.updateStuQuestionPaper(stuQuestionPaper);
    }

    /**
     * 批量删除题卷
     * 
     * @param ids 需要删除的题卷ID
     * @return 结果
     */
    @Override
    public int deleteStuQuestionPaperByIds(Long[] ids)
    {
        return stuQuestionPaperMapper.deleteStuQuestionPaperByIds(ids);
    }

    /**
     * 删除题卷信息
     * 
     * @param id 题卷ID
     * @return 结果
     */
    @Override
    public int deleteStuQuestionPaperById(Long id)
    {
        return stuQuestionPaperMapper.deleteStuQuestionPaperById(id);
    }
}
